package util;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class HtmlUtil {

	public static void inviaHome(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		request.getRequestDispatcher("/index.jsp").include(request, response);
	}
	
	public static void inviaHeader(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		request.getRequestDispatcher("/WEB-INF/include/header.jsp").include(request, response);
	}
	

	
	public static void inviaIntestazioneUtente(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		inviaIntestazioneVisitatore(request,response);
	}
	
	public static void inviaIntestazioneVisitatore(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		request.getRequestDispatcher("/WEB-INF/include/intestazione.jsp").include(request, response);

	
	
	}
	public static void includi(HttpServletRequest request, HttpServletResponse response,String pagina) throws ServletException, IOException
	{
			request.getRequestDispatcher(pagina).include(request, response);
	}
	
	public static void CompletaEdIncludi(HttpServletRequest request, HttpServletResponse response,String pagina) throws ServletException, IOException
	{
			inviaHeader(request,response);
			inviaIntestazioneUtente(request,response);
			includi(request,response,pagina);
			inviaFooter(request, response);
	}
	
	public static void inviaFooter(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		request.getRequestDispatcher("/WEB-INF/include/footer.jsp").include(request, response);
	}
	
	public static void redirect(HttpServletRequest request, HttpServletResponse response, String pagina) throws ServletException, IOException
	{
		response.sendRedirect(request.getContextPath() + pagina);
	}
	public static void forward(HttpServletRequest request, HttpServletResponse response, String pagina) throws ServletException, IOException
	{
		RequestDispatcher dispatcher = request.getRequestDispatcher(pagina);
		dispatcher.forward(request, response);
	}

	public static void inviaIntestazioneAmministratore(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		request.getRequestDispatcher("/WEB-INF/include/intestazioneAmministratore.jsp").include(request, response);
	}
	

	
}
